<?php
	/**
	This file is part of PEL.
		PEL is free software: you can redistribute it and/or modify
		it under the terms of the GNU General Public License as published by
		the Free Software Foundation, either version 3 of the License, or
		(at your option) any later version.
	    
		PEL is distributed in the hope that it will be useful,
		but WITHOUT ANY WARRANTY; without even the implied warranty of
		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
		GNU General Public License for more details.
	    
		You should have received a copy of the GNU General Public License
		along with PEL.  If not, see <http://www.gnu.org/licenses/>.
	* Elgg pel language individual view
	*/

	if (isset($vars['entity'])){
				$owner=$vars['entity']->getOwnerEntity();
		?>
		<div class="search_listing">
				<h4>
				<a href="<?php echo $vars['url']; ?>pg/pel/<?php echo $owner->username;?>">PEL de <?php echo $vars['entity']->getOwnerEntity()->name; ?></a>
					</h4>
			<div class="blog_post_icon">
		    <?php
		        echo elgg_view("profile/icon",array('entity' => $vars['entity']->getOwnerEntity(), 'size' => 'tiny'));
					//echo '<img src="'.$vars['entity']->getOwnerEntity()->getIcon('tiny').'" border="0" />';
			?>
	   </div>
			<p class="strapline">
        <?php
          echo elgg_echo('pel:creation');
          echo sprintf(elgg_echo("pel:strapline"), date("j/m/y",$vars['entity']->time_created));
          echo elgg_echo('pel:by');
        ?>
        <b>
          <?php	echo $vars['entity']->getOwnerEntity()->name; ?>
        </b>
        <?php $voir= elgg_echo('pel:voir'); ?>
        &nbsp;&nbsp; 
        <!-- display the actual pel post -->

					<?php
					$title_label= elgg_echo('pel:native')." :";
					$pel=ucfirst($vars['entity']->description);
					$edit=elgg_echo('pel:editlang');
					$delete=elgg_echo('pel:deletelang');
					$voir=elgg_echo('pel:voir');
					$ent=get_entities_from_metadata('parent_guid',$vars['entity']->getGUID(),"object",'lang');
					$otherlang=elgg_echo('pel:friend:nolang');
				
					if(is_array($ent))
					{
						foreach($ent as $e){
							$otherlang=elgg_echo('pel:otherlang')." :";
							$entity=get_entity($e->guid);
							$guid=$entity->guid;
							$lang=ucfirst($entity->description);
							$text.="<tr><td><img src=\"".$vars['url']."mod/pel/graphics/owner_block_menu_arrow.gif\" alt=\"owner block menu\" /></td><td><h4>$lang</h4></td>
							<td><a href=\"".$vars['url']."mod/pel/viewlang.php?lang=$guid\"><img src=\"".$vars['url']."mod/pel/graphics/voir.gif\" alt=\"voir\" /> $voir</a></td>";
						}
					}
				?>
					<h4><?php echo $title_label; ?> <?php echo $pel; ?></h4>
					<h4><?php echo $otherlang ; ?></h4>
					<table id="tablang">
						<?php echo $text; ?>
					</table>
			</p>
        <!-- display edit options if it is the pel post owner -->
     

		</div>
  	<?php
    // If we've been asked to display the full view
    if (isset($vars['full']) && $vars['full'] == true){ ?>
			 <p class="options">
        <?php
          if ($vars['entity']->canEdit()){
            // Allow the menu to be extended
            echo elgg_view("editmenu",array('entity' => $vars['entity']));
          }
        ?>
      </p><?php
    	echo elgg_view_comments($vars['entity']);
    }		
	}
?>